// ==========================================================================
// GFast自动生成dao internal操作代码。
// 生成日期：2024-04-24 15:48:40
// 生成路径: internal/app/business/dao/internal/performances.go
// 生成人：周志雄
// desc:演出节目
// company:云南奇讯科技有限公司
// ==========================================================================


package internal


import (
    "context"
    "github.com/gogf/gf/v2/database/gdb"
    "github.com/gogf/gf/v2/frame/g"
)


// PerformancesDao is the manager for logic model data accessing and custom defined data operations functions management.
type PerformancesDao struct {
    table   string         // Table is the underlying table name of the DAO.
    group   string         // Group is the database configuration group name of current DAO.
    columns PerformancesColumns // Columns is the short type for Columns, which contains all the column names of Table for convenient usage.
}


// PerformancesColumns defines and stores column names for table performances.
type PerformancesColumns struct {    
    Id  string  // 主键ID    
    PerformanceName  string  // 节目名    
    PerformanceDate  string  // 演出日期    
    PerformanceTime  string  // 演出时间    
    StartSaleTime  string  // 开售时间    
    TicketReclaimTime  string  // 直通车票号回收时间    
    TicketPickupTime  string  // 取票时间    
    VenueId  string  // 场馆ID    
    ProgramTypeId  string  // 节目类型ID    
    CreatedAt  string  // 创建时间    
    UpdatedAt  string  // 更新时间    
}


var performancesColumns = PerformancesColumns{    
    Id:  "id",    
    PerformanceName:  "performance_name",    
    PerformanceDate:  "performance_date",    
    PerformanceTime:  "performance_time",    
    StartSaleTime:  "start_sale_time",    
    TicketReclaimTime:  "ticket_reclaim_time",    
    TicketPickupTime:  "ticket_pickup_time",    
    VenueId:  "venue_id",    
    ProgramTypeId:  "program_type_id",    
    CreatedAt:  "created_at",    
    UpdatedAt:  "updated_at",    
}


// NewPerformancesDao creates and returns a new DAO object for table data access.
func NewPerformancesDao() *PerformancesDao {
	return &PerformancesDao{
        group:    "default",
        table: "performances",
        columns:performancesColumns,
	}
}


// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *PerformancesDao) DB() gdb.DB {
	return g.DB(dao.group)
}


// Table returns the table name of current dao.
func (dao *PerformancesDao) Table() string {
	return dao.table
}


// Columns returns all column names of current dao.
func (dao *PerformancesDao) Columns() PerformancesColumns {
	return dao.columns
}


// Group returns the configuration group name of database of current dao.
func (dao *PerformancesDao) Group() string {
	return dao.group
}


// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *PerformancesDao) Ctx(ctx context.Context) *gdb.Model {
	return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}


// Transaction wraps the transaction logic using function f.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *PerformancesDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
	return dao.Ctx(ctx).Transaction(ctx, f)
}